function mySwiper(swiper, point, mouse = false, bg_img = null) {
  let current_num = 0;
  let timer = null;

  // 生成小点
  for (let i = 0; i <= swiper.childElementCount - 1; i++) {
    point.appendChild(document.createElement("li"));
  }
  point.firstElementChild.classList.add("active");

  // 自动轮播
  auto_carousel();
  function auto_carousel() {
    timer = setInterval(() => {
      if (++current_num >= point.childElementCount) {
        current_num = 0;
      }
      swiper_fn();
      point_fn();
      bg_active();
    }, 3000);
  }

  // 小点的点击事件
  [...point.children].forEach((obj, idx) => {
    obj.addEventListener("click", () => {
      current_num = idx;
      clearInterval(timer);
      swiper_fn();
      point_fn();
      auto_carousel();
      bg_active();
    });
  });

  // 选中小圆点
  function point_fn() {
    [...point.children].forEach((obj) => obj.classList.remove("active"));
    point.children[current_num].classList.add("active");
  }

  // 选中轮播图片
  function swiper_fn() {
    [...swiper.children].forEach((obj) => obj.classList.remove("active"));
    swiper.children[current_num].classList.add("active");
  }

  if (mouse) {
    // 鼠标进入停止轮播
    [...swiper.children].forEach((obj) => {
      obj.addEventListener("mouseenter", () => {
        clearInterval(timer);
      });
    });

    // 鼠标移出开启轮播
    [...swiper.children].forEach((obj) => {
      obj.addEventListener("mouseleave", () => {
        auto_carousel();
      });
    });
  }

  // 底下背景图
  function bg_active() {
    if (bg_img) {
      [...bg_img.children].forEach((obj) => obj.classList.remove("active"));
      bg_img.children[current_num].classList.add("active");
    }
  }
}
